<!DOCTYPE html>
<html>
{include file="public/header" /}
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <form class="layui-form" action="" lay-filter="component-form-group">
            <!--<div class="layui-card-header">表单组合</div>-->
            <div class="layui-card-body" style="padding: 15px;">
                <input type="hidden" name="id" value="{$item.id}">
                <div class="layui-form-item">
                    <label class="layui-form-label">账号</label>
                    <div class="layui-input-block">
                        <input type="text" name="" lay-verify="required" readonly autocomplete="off" placeholder="请输入"
                               value="{$item.username}"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-block">
                        <input type="text" name="password"  placeholder="不修改 使用原密码" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">联系方式</label>
                    <div class="layui-input-block">
                        <input type="tel" name="phone" lay-verify="required" autocomplete="off" placeholder="请输入"
                               value="{$item.phone}"
                               class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="status" value="1" title="正常"  {if condition="$item.status eq 1"}checked=""{/if}>
                        <input type="radio" name="status" value="0" title="禁用" {if condition="$item.status eq 0"}checked=""{/if}>

                    </div>
                </div>

                <!--<div class="layui-form-item">-->
                <!--<div class="layui-input-block">-->
                <!--<div class="layui-footer">-->
                <!--<button class="layui-btn" lay-submit="" lay-filter="component-form-demo1">立即提交</button>-->
                <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                <!--</div>-->
                <!--</div>-->
                <!--</div>-->

            </div>
            <div class="layui-form-item form-footer2">
                <div class="layui-input-block">
                    <div class="layui-footer">
                        <button class="layui-btn" lay-submit="" lay-filter="component-form-demo1">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </div>
        </form>

    </div>
</div>

<script>

    layui.use(['form', 'laydate'], function () {
        var $ = layui.$
            , element = layui.element
            , layer = layui.layer
            , laydate = layui.laydate
            , form = layui.form;

        form.render(null, 'component-form-group');

        laydate.render({
            elem: '#LAY-component-form-group-date'
        });

        /* 自定义验证规则 */
        form.verify({
            title: function (value) {
//      if(value.length < 5){
//        return '标题至少得5个字符啊';
//      }
            }
            , pass: [/(.+){6,12}$/, '密码必须6到12位']
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });

        /* 监听指定开关 */
        form.on('switch(component-form-switchTest)', function (data) {
            layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });

        /* 监听提交 */
        form.on('submit(component-form-demo1)', function (data) {

            $.post("{:url('edit')}",data.field,function (res) {
                if (res.code == 1) {

                    //更新父元素
                    parent.init();
                    parent.layer.closeAll();
                    parent.layer.msg(res.msg, {icon: 1})
                    return false;
                } else {
                    parent.layer.msg(res.msg, {icon: 2})
                    return false;
                }
            });



            return false;
        });
    });
</script>

</body>
</html>










